Ext.namespace('iOS.App.Notes');

Ext.define('NotesList', {
    extend : 'BaseListView',

    statics : {
        ViewCls       : 'notes-list',
        BaseCls       : 'list-view',
        ListContainer : 'list-container',
        ListCls       : 'ios-list',
        ListContent   : 'list-content',
        ListTop       : 'list-top',
        ListBottom    : 'list-bottom',
        ListText      : 'list-text',
        ListTime      : 'list-time',
        ListSpace     : 'list-space',
        NotesCard     : 'notes-card',
        NotesContent  : 'notes-content',
        NotesToolBar  : 'notes-bar'
    },

    /*
     * 单击时背景色的改变
     */
    _clickedColor: 'rgba(172, 89, 61, 0.35)',

    _eventList: [
        ['beginEdit'],
        ['finishEdit']
    ],

    _initInnerDom: function(){
        var htmlTop    = [
            '<div class="',this.self.ListTop,'">',
            '</div>'
        ],
        htmlBottom = [
            '<div class="',this.self.ListBottom,'">',
            '</div>'
        ];
        this.getElCache().append(htmlTop.join(''));

        this.callParent();

        this.getElCache().append(htmlBottom.join(''));
        iOS.ViewManager.notify(this.self.NotesToolBar, 'changeBtn', [this.toolBarBtnCfg]);
    },

    clickHandler: function(e){
        var that  = e.data.scope || this,
            sttc  = that.self,
            $this = $(this),
            index = $this.index();
        $this.css('background', that._clickedColor);
        setTimeout(function(){
            $this.css('background', '');
        }, 450);//此处时间对应为cardView中card的动画时间，不得已而为之。
        iOS.ViewManager.notify(sttc.NotesCard,   'changeCard',  [sttc.NotesContent]);
        //iOS.ViewManager.notify(sttc.NotesContent, 'changeContent', [index]);
    },

    /*
     * 列表内容
     */
    _initListHtml: function(){
        var sttc      = this.self,
            listHtml  = [];
        for(var i = 0; i < 30; i++){
            listHtml.push(
                '<div class="' + sttc.ListContent + '">' +
                    '<div class="' + sttc.ListText + '">' +
                        'hello world' +
                    '</div>' + 
                    '<div class="' + sttc.ListSpace + '">' + 
                    '</div>' +
                    '<div class="' + sttc.ListTime + '">' +
                        '4月27号' +
                    '</div>' +
                '</div>'
            );
        }
        this._listHtml = listHtml;
    }
});

iOS.App.Notes.NotesList = NotesList;